<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <link href="./index.css" type="text/css" rel="Stylesheet">
    <script src="js/spark-md5.js" type="text/javascript"></script>
</head>
<body>
<h1>demo</h1>
账号：<input type="account" value="" id="account">
<br/>
密码:<input type="password" value="" id="password">
<br/>
<button id="login">登录</button>

<div id="file">上传文件</div>
<div id="progress">
</div>
<script src="./index.js" type="module"></script>




<script>
    let ip = "";
    let gateway1 = "http://127.0.0.1:8813";
    /**
     * 登录
     */
    document.getElementById("login").onclick = function () {
        let httpRequest = new XMLHttpRequest();
        httpRequest.open("POST", ip + gateway1 + "/login");
        httpRequest.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
        httpRequest.onloadend = function (res) {
            console.log(res);
            if (res.target['status'] === 200) {
                let data = JSON.parse(res.target.responseText)
                sessionStorage.setItem("token", data.token)
                alert("登录成功!")
            }
        };
        httpRequest.send(JSON.stringify({
            account: document.getElementById("account").value,
            password: document.getElementById("password").value
        }));
    };
</script>
</body>
</html>
